379A - New Year Candles - CodeForces Solution


implementation *1000

Please click on ads to support us..

Python Code:

l=list(map(int,input().rstrip().split()))
main=l[0]
n=l[1]
sum=0
while main!=0:
    main-=1
    sum+=1
    if sum%n==0:
        main+=1
print(sum)

C++ Code:

#include <bits/stdc++.h> 
using ll = long long;
using namespace std;
int main() {
    
    ll l, b, nl = 0, time = 0, n;
    cin>>l>>b;
    time += l;
    nl += l;
    while (true) {
        if (nl/b > 0) {
            time += nl/b;
            n = nl;
            nl -= (nl/b)*b;
            nl += n/b;
        }
        else break;
    }
    cout<<time;
}


Comments

Submit
0 Comments
More Questions

Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup